{layout name="layout" /}

<div class="Hui-article">
	<article class="cl pd-20">
		<form action="" method="post" class="form form-horizontal" id="form-admin-powers-add">
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2">上级权限</label>
				<div class="formControls col-xs-8 col-sm-2">
					<span class="select-box" style="width:150px;">
						<select class="select" id="pid" name="pid">
							<option value="0" {eq name='data.pid' value="0" }selected{/eq}>--新增顶级权限--</option>
							{foreach $powers as $k=>$op}
							<option value="{$k}" {eq name='data.pid' value="$k" }selected{/eq}>----{$op}----</option>
							{/foreach}
						</select>
					</span>
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-2 col-sm-2">
					<span class="c-red">*</span> 权限名称：</label>
				<div class="formControls col-xs-6 col-sm-3">
					<input type="text" class="input-text" value="{$data.name}" id="name" name="name" />
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-2 col-sm-2">
					<span class="c-red">*</span> 控制器或方法名: </label>
				<div class="formControls col-xs-6 col-sm-3">
					<input type="text" class="input-text" value="{$data.method}" id="method" name="method" />
				</div>
				<span style="color:red;">* 小写字母</span>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-2 col-sm-2">备注：</label>
				<div class="formControls col-xs-8 col-sm-4">
					<textarea id="description" name="description" cols="" rows="" class="textarea" dragonfly="true"
					    onKeyUp="textarealength(this,100)">{$data.description}</textarea>
					<p class="textarea-numberbar">
						<em class="textarea-length">0</em>/100</p>
				</div>
			</div>
			<div class="row cl">
				<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
					<button type="submit" class="btn btn-success radius" id="admin-powers-save" name="">确&nbsp;定</button>
					<button type="button" class="btn btn-default radius" onclick="window.history.back();" style="margin-left:20px;">取&nbsp;消</button>
				</div>
			</div>
		</form>
	</article>
</div>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
	$(function () {
		$("#form-admin-powers-add").submit(function () {
			var desc = $("#description").val();

			if (!$("#name").val() || !$("#method").val) {
				layer.msg('权限名 or 控制器/方法', {
					icon: 5,
					time: 1000
				});

				return false;
			}

			if (getblen(desc) > 100) {
				layer.msg('备注过长', {
					icon: 5,
					time: 1000
				});

				return false;
			}
		})
	})
</script>